package _interview150;

/**
 * 58. 最后一个单词的长度
 */
public class No58 {
    public int lengthOfLastWord(String s) {
        int right = s.length() - 1;
        while (s.charAt(right) == ' ') right--;
        int ans = 0;
        while (right >= 0 && s.charAt(right--) != ' ') ans++;
        return ans;
    }
}
